package com.fengsir.controller;

import com.fengsir.entity.Student;
import com.fengsir.mapper.StudentMapper;
import com.fengsir.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;

/**
 * @author fengzeng
 * @create 2021/5/11 21:58
 */
@RestController
public class StudentController {

  @GetMapping("/getStudent")
  public List getStudent() {
    ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
    StudentMapper userMapper = (StudentMapper) context.getBean("studentMapper");
    List<Student> students = userMapper.getStudents();
    return students;
  }

  @GetMapping("/test")
  public String test() {
    return "success";
  }
}
